<?php

include_once 'Shared/Models/Mail.php';
include_once 'Shared/Models/User.php';
class contact_IndexController extends Vi_Controller_Action
{
	public function indexAction()
	{
		/**
		 * Display tempalte
		 */
	    $this->view->headTitle('Contact Us');
	    $this->view->menuId = 'contactus';
	    
	    /**
	     * Get post data
	     */
	    $data = $this->_getParam('data', false);
	    
	    if (false != $data) {
	        /**
	         * Get admin
	         */
	        $objUser = new Models_User();
	        //$admin = $objUser->getByUserName('admin'); //delete 20110709
	        /**
	         * Send message
	         */
	        //20110709
	        $portalAlias = Vi_Registry::getAppName();
	        $objPortal = new Models_Portal();
	        $portal = $objPortal->getPortalbyAlias($portalAlias);
	        $portal = current($portal);
	        $manager = $objUser->getByUserId($portal['user_id']);
	        //20110709
	        $objMail = new Models_Mail();
	        //$objMail->sendHtmlMail('contact', $data, $admin['email']); //delete 20110709
	        $objMail->sendHtmlMail('contact', $data, $manager['email'], $data['subject']); //modify 20110709
	    }
	    
	    $this->view->data = $data;
	}
}